﻿//AcademicPlanner - course registration planning web app.
//Copyright (C) 2009  Boubacar Diallo

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AcademicPlanner.Framework.Libraries.Auth
{
	/// <summary>
	/// Represents the result of an authentication request.
	/// </summary>
	/// <version>1.0</version>
	/// <since>1.0</since>
	public struct AuthenticationResult
	{
		internal bool authentic;

		internal string userIdentifier;

		/// <summary>
		/// Gets whether the user attempted to be authenticated is authentic or not.
		/// </summary>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public bool IsAuthentic { get { return authentic; } }

		/// <summary>
		/// Gets the user attempted to be authenticated.
		/// </summary>
		/// <version>1.0</version>
		/// <since>1.0</since>
		public string UserIdentifier { get { return userIdentifier; } }
	}

	/// <summary>
	/// Provices authentication services.
	/// </summary>
	/// <version>1.0</version>
	/// <since>1.0</since>
	public interface IAuthenticator
	{
		/// <summary>
		/// Authenticates a user with a password.
		/// </summary>
		/// <param name="pUser">The user's identifier.</param>
		/// <param name="pPassword">The user's password.</param>
		/// <returns>
		/// An <c>AuthenticationResult</c> detailing the result of the authentication request.
		/// </returns>
		/// <version>1.0</version>
		/// <since>1.0</since>
		AuthenticationResult Authenticate(string pUser, string pPassword);

		/// <summary>
		/// Authenticates a user without a password.
		/// </summary>
		/// <param name="pUser">The user's identifier.</param>
		/// <returns>
		/// An <c>AuthenticationResult</c> detailing the result of the authentication request.
		/// </returns>
		/// <version>1.0</version>
		/// <since>1.0</since>
		AuthenticationResult Authenticate(string pUser);
	}
}
